﻿CREATE PROCEDURE [dbo].[CashRegisterLinesSelect]
AS--строки чека и строки возвратов по чеку
	SET NOCOUNT ON;
SELECT L.Id,  L.DocId, L.PartyId, 
CASE WHEN D.DocTypeId = 3 THEN L.Qntty * (-1) ELSE L.Qntty END AS Qntty, 
CASE WHEN D.DocTypeId = 3 THEN L.RetailSum * (-1.0) ELSE L.RetailSum END AS RetailSum,
L.ReturnLineId,
L.Note, L.MD, L.MW 
FROM CA.GoodsDocLines AS L WITH (NOLOCK)
INNER JOIN CA.Documents AS D WITH (NOLOCK) 
ON L.DocId = D.Id AND (D.DocTypeId = 3 OR D.DocTypeId = 7)
